/**
 * futures : masterlink.futures.controller.IndexController.java
 */
package masterlink.futures.controller;

import javax.servlet.http.HttpServletRequest;

import masterlink.futures.dao.EmpSettingDao;
import masterlink.futures.util.WebUtils;
import masterlink.futures.vo.EmpSetting;
import masterlink.futures.vo.Employee;
import masterlink.futures.vo.Function;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * TODO Write the description
 *
 * @author : tonyyang
 * Create date : 2011/9/30
 * @version 1.0.0	
 */
@Controller
@RequestMapping(value = "/setting")
public class EmpSettingController extends BasicController{
	
	@Autowired
	private EmpSettingDao empSettingDao;
	
	@RequestMapping(value="/set1/{id}",method=RequestMethod.GET)
	public void set1(@PathVariable("id")Integer id,HttpServletRequest req){
		Employee emp=WebUtils.getLogEmployee(req);
		Function fun=WebUtils.getFunction(req);
		EmpSetting es=WebUtils.getSetting(req);
		log.trace("{} setting set1 for fun {} with id:"+id,emp.getEmpno(),fun);
		es.addSetting1(id);
		empSettingDao.update(es);
		WebUtils.setSetting(es, req);
	}
	
	@RequestMapping(value="/remove1/{id}",method=RequestMethod.GET)
	public void remove1(@PathVariable("id")Integer id,HttpServletRequest req){
		Employee emp=WebUtils.getLogEmployee(req);
		Function fun=WebUtils.getFunction(req);
		EmpSetting es=WebUtils.getSetting(req);
		log.trace("{} remove set1 for fun {} with id:"+id,emp.getEmpno(),fun);
		es.removeSetting1(id);
		empSettingDao.update(es);
		WebUtils.setSetting(es, req);
	}
	
	@RequestMapping(value="/set2/{id}",method=RequestMethod.GET)
	public void set2(@PathVariable("id")Integer id,HttpServletRequest req){
		Employee emp=WebUtils.getLogEmployee(req);
		Function fun=WebUtils.getFunction(req);
		EmpSetting es=WebUtils.getSetting(req);
		log.trace("{} setting set2 for fun {} with id:"+id,emp.getEmpno(),fun);
		es.addSetting2(id);
		empSettingDao.update(es);
		WebUtils.setSetting(es, req);
	}
	
	@RequestMapping(value="/remove2/{id}",method=RequestMethod.GET)
	public void remove2(@PathVariable("id")Integer id,HttpServletRequest req){
		Employee emp=WebUtils.getLogEmployee(req);
		Function fun=WebUtils.getFunction(req);
		EmpSetting es=WebUtils.getSetting(req);
		log.trace("{} remove set2 for fun {} with id:"+id,emp.getEmpno(),fun);
		es.removeSetting1(id);
		empSettingDao.update(es);
		WebUtils.setSetting(es, req);
	}
	
}
